import frida,sys

# send(arguments[0]);
# send(arguments[1]);
jscode = '''
Java.perform(function(){
    var init_gorgon = Java.use('com.ss.sys.ces.gg.tt.init_gorgon');
    init_gorgon.init_gorgon.implementation = function(){
        console.log("HOOK Start...");
        send(this.init_gorgon());
        send("Success!");
    }
})
'''
device = frida.get_usb_device()
pid = device . spawn(["com.ss.android.ugc.aweme"])
session = device.attach(pid)
device.resume(pid)
scr ='''
Interceptor.attach(Module.findExportByName("libcms.so"，"open"), {
    onEnter: function(args,arg) {
        send("open called!");
};
    onLeave:function(retval){
}
});
'''


def on_message(message,data):
    if message['type'] == 'send':
        print("[*]{0}".format(message['payload']))
    else:
        print(message)
process = frida.get_remote_device().attach('com.ss.android.ugc.aweme')
script = process.create_script(scr)
script.on("message",on_message)
script.load()
sys.stdin.read()